﻿using System;
using System.Collections.Generic;
using System.Linq;
using OpenHttpServer;
using OpenHttpServer.Models;

using System.Threading;


namespace VIID.Server
{
    /// <summary>
    /// GAT1400 服务器端
    /// </summary>
    public class Server
    {
        public static string BaseURL { get; set; }
        private static HttpServer httpServer;
        //private static HttpClient httpClient;
        private static Thread thread;
        
        
        public static ServerOptions _options;//服务端配置
        public static MessageDelegate messageCallback = null;

        public class ServerOptions
        {
            /// <summary>
            /// 服务器监听端口号
            /// </summary>
            public int port { get; set; } = 1400;
            public string realm { get; set; } = "viid";
            /// <summary>
            /// 心跳超时(秒) 默认90
            /// </summary>
            public int timeout { get; set; } = 90;
            /// <summary>
            /// 本地URL(影响订阅返回URL)
            /// </summary>
            public string localUri { get; set; } 
            /// <summary>
            /// 机构代码 12位
            /// </summary>
            public string groupcode { get; set; }
            /// <summary>
            /// 服务器编号
            /// </summary>
            public string serverID { get; set; }
            /// <summary>
            /// 日志模式
            /// </summary>
            public bool logMode { get; set; } = true;
            /// <summary>
            /// 服务器验证模式
            /// 0=不验证 1=验证 2=自动注册
            /// </summary>
            public int authMode { get; set; } = 1;
            /// <summary>
            /// 平台编号（只读）
            /// 机构代码 + 服务器编号
            /// </summary>
            public string platformID { get { return groupcode + serverID; } }
        }
        
        /// <summary>
        /// 停止服务器
        /// </summary>
        public void Stop()
        {
            
            httpServer.Stop();
            //thread.Abort();
        }

        public Server()
        {
            //httpClient = new HttpClient();
            //httpClient.DefaultRequestHeaders.Accept.Add(new MediaTypeWithQualityHeaderValue("application/VIID+JSON"));
            //httpClient.DefaultRequestHeaders.Add("User-Agent", "GAT1400 Client 1.0");
        }
        /// <summary>
        /// 初始化设置服务器选项
        /// </summary>
        /// <param name="options">服务器设置</param>
        /// <param name="callback1">消息回调（信息）</param>
        /// <param name="callback2">消息回调（系统）</param>
        public void setOptions(ServerOptions options, MessageDelegate callback)
        {
            _options = options;
            messageCallback = callback;
            //httpClient.DefaultRequestHeaders.Add("User-Identify", _options.platformID);
        }

        /// <summary>
        /// 启动服务器
        /// </summary>
        /// <param name="webPort">服务端口，默认80</param>
        /// <returns></returns>
        public bool Start()
        {
            Console.WriteLine("加载路由");
            //启动HTTP
            var route_config = new List<Route>()
            {
                //公共功能
                new Route(){UrlRegex="/VIID/System/Register",Method= HttpMethods.POST,Name = "注册",Callable = System.Register},
                new Route(){UrlRegex="/VIID/System/UnRegister",Method= HttpMethods.POST,Name = "注销",Callable = System.UnRegister},
                new Route(){UrlRegex="/VIID/System/Keepalive",Method= HttpMethods.POST,Name = "保活",Callable = System.Keepalive},
                new Route(){UrlRegex="/VIID/System/Time",Method= HttpMethods.GET,Name = "校时",Callable = System.Time},
                //采集接口
                new Route(){UrlRegex="/VIID/VideoSlices",Method= HttpMethods.POST,Name = "上传自动采集视频片段",Callable = VideoSlices.POST},
                new Route(){UrlRegex="/VIID/VideoSlices/(.*)/Data$",Method= HttpMethods.POST,Name = "上传自动采集视频片段数据",Callable = VideoSlices.ID.Data.POST},
                new Route(){UrlRegex="/VIID/Images",Method= HttpMethods.POST,Name = "上传自动采集图像",Callable = Images.POST},
                new Route(){UrlRegex="/VIID/Images/(.*)/Data$",Method= HttpMethods.POST,Name = "上传自动采集图像数据",Callable = Images.ID.Data.POST},
                new Route(){UrlRegex="/VIID/Files",Method= HttpMethods.POST,Name = "上传自动采集文件",Callable = Files.POST},
                new Route(){UrlRegex="/VIID/Files/(.*)/Data$",Method= HttpMethods.POST,Name = "上传自动采集文件数据",Callable = Files.ID.Data.POST},
                new Route(){UrlRegex="/VIID/Persons",Method= HttpMethods.POST,Name = "上传自动采集人员",Callable = Persons.POST},
                new Route(){UrlRegex="/VIID/Faces",Method= HttpMethods.POST,Name = "上传自动采集人脸",Callable = Faces.POST},
                new Route(){UrlRegex="/VIID/MotorVehicles",Method= HttpMethods.POST,Name = "上传自动采集机动车",Callable = MotorVehicles.POST},
                new Route(){UrlRegex="/VIID/NonMotorVehicles",Method= HttpMethods.POST,Name = "上传自动采集非机动车",Callable = NonMotorVehicles.POST},
                new Route(){UrlRegex="/VIID/Things",Method= HttpMethods.POST,Name = "上传自动采集物品",Callable = Things.POST},
                new Route(){UrlRegex="/VIID/Scenes",Method= HttpMethods.POST,Name = "上传自动采集场景",Callable = Scenes.POST},
                new Route(){UrlRegex="/VIID/VideoLabels",Method= HttpMethods.POST,Name = "上传自动采集视频图像标签",Callable = VideoLabels.POST},
                new Route(){UrlRegex="/VIID/AnalysisRules",Method= HttpMethods.POST,Name = "上传视频图像分析规则",Callable = AnalysisRules.POST},
                //级联接口--订阅通知
                new Route(){UrlRegex="/VIID/Subscribes",Method= HttpMethods.POST,Name = "批量订阅",Callable = Subscribes.POST},
                new Route(){UrlRegex="^/VIID/Subscribes$",Method= HttpMethods.PUT,Name = "批量修改订阅任务",Callable = Subscribes.PUT},
                new Route(){UrlRegex="/VIID/Subscribes",Method= HttpMethods.DELETE,Name = "批量删除订阅任务",Callable = Subscribes.DELETE},
                new Route(){UrlRegex="^/VIID/Subscribes/(.*)$",Method= HttpMethods.PUT,Name = "取消订阅",Callable = Subscribes.ID.PUT},
                new Route(){UrlRegex="/VIID/SubscribeNotifications",Method= HttpMethods.POST,Name = "通知",Callable = SubscribeNotifications.POST},
                new Route(){UrlRegex="/VIID/SubscribeNotifications",Method= HttpMethods.DELETE,Name = "删除通知记录",Callable = SubscribeNotifications.DELETE},
                //级联接口--布控告警
                new Route(){UrlRegex="/VIID/Dispositions",Method= HttpMethods.POST,Name = "批量布控",Callable = Dispositions.POST},
                new Route(){UrlRegex="^/VIID/Dispositions$",Method= HttpMethods.PUT,Name = "批量修改布控任务",Callable = Dispositions.PUT},
                new Route(){UrlRegex="/VIID/Dispositions",Method= HttpMethods.DELETE,Name = "批量删除布控任务",Callable = Dispositions.DELETE},
                new Route(){UrlRegex="/VIID/Dispositions/(.*)$",Method= HttpMethods.PUT,Name = "撤控",Callable = Dispositions.ID.PUT},
                new Route(){UrlRegex="/VIID/DispositionNotifications",Method= HttpMethods.POST,Name = "告警",Callable = DispositionNotifications.POST},
                new Route(){UrlRegex="/VIID/DispositionNotifications",Method= HttpMethods.DELETE,Name = "删除告警记录",Callable = DispositionNotifications.DELETE},
                //数据服务接口--查询更新采集设备或采集系统
                new Route(){UrlRegex="/VIID/APEs",Method= HttpMethods.GET,Name = "查询采集设备",Callable = APEs.GET},
                new Route(){UrlRegex="/VIID/APEs",Method= HttpMethods.PUT,Name = "更改采集设备口令",Callable = APEs.PUT},
                new Route(){UrlRegex="/VIID/APSs",Method= HttpMethods.GET,Name = "查询采集系统",Callable = APSs.GET},
                new Route(){UrlRegex="/VIID/Tollgates",Method= HttpMethods.GET,Name = "查询视频卡口",Callable = Tollgates.GET},
                new Route(){UrlRegex="/VIID/Lanes",Method= HttpMethods.GET,Name = "查询车道",Callable = Lanes.GET},
                //数据服务接口--特征属性查询
                new Route(){UrlRegex="/VIID/VideoSlices",Method= HttpMethods.GET,Name = "批量查询视频片段",Callable = VideoSlices.GET},
                new Route(){UrlRegex="/VIID/VideoSlices/(.*)$",Method= HttpMethods.GET,Name = "查询单个视频片段",Callable = VideoSlices.ID.GET},
                new Route(){UrlRegex="/VIID/VideoSlices/(.*)/Info$",Method= HttpMethods.GET,Name = "查询视频片段对象信息",Callable = VideoSlices.ID.Info.GET},
                new Route(){UrlRegex="/VIID/VideoSlices/(.*)/Data$",Method= HttpMethods.GET,Name = "下载视频片段数据",Callable = VideoSlices.ID.Data.GET},
                new Route(){UrlRegex="/VIID/Images",Method= HttpMethods.GET,Name = "批量查询图像",Callable = Images.GET},
                new Route(){UrlRegex="/VIID/Images/(.*)$",Method= HttpMethods.GET,Name = "查询单个图像",Callable = Images.ID.GET},
                new Route(){UrlRegex="/VIID/Images/(.*)/Info$",Method= HttpMethods.GET,Name = "查询图像对象信息",Callable = Images.ID.Info.GET},
                new Route(){UrlRegex="/VIID/Images/(.*)/Data$",Method= HttpMethods.GET,Name = "下载图像数据",Callable = Images.ID.Data.GET},
                new Route(){UrlRegex="/VIID/Files",Method= HttpMethods.GET,Name = "查询文件",Callable = Files.GET},
                new Route(){UrlRegex="/VIID/Files/(.*)$",Method= HttpMethods.GET,Name = "查询单个文件",Callable = Files.ID.GET},
                new Route(){UrlRegex="/VIID/Files/(.*)/Info$",Method= HttpMethods.GET,Name = "查询文件对象信息",Callable = Files.ID.Info.GET},
                new Route(){UrlRegex="/VIID/Files/(.*)/Data$",Method= HttpMethods.GET,Name = "下载文件数据",Callable = Files.ID.Data.GET},
                new Route(){UrlRegex="/VIID/Persons",Method= HttpMethods.GET,Name = "查询人员",Callable = Persons.GET},
                new Route(){UrlRegex="/VIID/Persons/(.*)$",Method= HttpMethods.GET,Name = "查询单个人员",Callable = Persons.ID.GET},
                new Route(){UrlRegex="/VIID/Faces",Method= HttpMethods.GET,Name = "批量查询人脸",Callable = Faces.GET},
                new Route(){UrlRegex="/VIID/Faces/(.*)$",Method= HttpMethods.GET,Name = "查询单个人脸",Callable = Faces.ID.GET},
                new Route(){UrlRegex="/VIID/MotorVehicles",Method= HttpMethods.GET,Name = "批量查询机动车",Callable = MotorVehicles.GET},
                new Route(){UrlRegex="/VIID/MotorVehicles/(.*)$",Method= HttpMethods.GET,Name = "查询单个机动车",Callable = MotorVehicles.ID.GET},
                new Route(){UrlRegex="/VIID/NonMotorVehicles",Method= HttpMethods.GET,Name = "批量查询非机动车",Callable = NonMotorVehicles.GET},
                new Route(){UrlRegex="/VIID/NonMotorVehicles/(.*)$",Method= HttpMethods.GET,Name = "查询单个非机动车",Callable = NonMotorVehicles.ID.GET},
                new Route(){UrlRegex="/VIID/Things",Method= HttpMethods.GET,Name = "批量查询物品",Callable = Things.GET},
                new Route(){UrlRegex="/VIID/Things/(.*)$",Method= HttpMethods.GET,Name = "查询单个物品",Callable = Things.ID.GET},
                new Route(){UrlRegex="/VIID/Scenes",Method= HttpMethods.GET,Name = "批量查询场景",Callable = Scenes.GET},
                new Route(){UrlRegex="/VIID/Scenes/(.*)$",Method= HttpMethods.GET,Name = "查询单个场景",Callable = Scenes.ID.GET},
                new Route(){UrlRegex="/VIID/Cases",Method= HttpMethods.GET,Name = "批量查询视频案事件",Callable = Cases.GET},
                new Route(){UrlRegex="/VIID/Cases/(.*)$",Method= HttpMethods.GET,Name = "查询单个视频案事件",Callable = Cases.ID.GET},
                new Route(){UrlRegex="/VIID/Cases/(.*)/Info$",Method= HttpMethods.GET,Name = "查询视频案事件对象信息",Callable = Cases.ID.Info.GET},
                new Route(){UrlRegex="/VIID/Dispositions",Method= HttpMethods.GET,Name = "查询布控任务",Callable = Dispositions.GET},
                new Route(){UrlRegex="/VIID/DispositionNotifications",Method= HttpMethods.GET,Name = "查询告警记录",Callable = DispositionNotifications.GET},
                new Route(){UrlRegex="/VIID/Subscribes",Method= HttpMethods.GET,Name = "查询订阅任务",Callable = Subscribes.GET},
                new Route(){UrlRegex="/VIID/SubscribeNotifications",Method= HttpMethods.GET,Name = "查询通知记录",Callable = SubscribeNotifications.GET},
                new Route(){UrlRegex="/VIID/AnalysisRules",Method= HttpMethods.GET,Name = "查询视频图像分析规则",Callable = AnalysisRules.GET},
                new Route(){UrlRegex="/VIID/VideoLabels",Method= HttpMethods.GET,Name = "查询视频图像标签",Callable = VideoLabels.GET},
                //数据服务接口--人工采集视频图像信息对象
                new Route(){UrlRegex="/VIID/Cases",Method= HttpMethods.POST,Name = "批量创建视频案事件",Callable = Cases.POST},
                new Route(){UrlRegex="/VIID/Cases/(.*)$",Method= HttpMethods.PUT,Name = "更新单个视频案事件",Callable = Cases.ID.PUT},
                new Route(){UrlRegex="/VIID/Cases/(.*)$",Method= HttpMethods.DELETE,Name = "删除单个视频案事件",Callable = Cases.ID.DELETE},
                new Route(){UrlRegex="/VIID/Cases/(.*)/Info$",Method= HttpMethods.PUT,Name = "更新视频案事件对象信息",Callable = Cases.ID.Info.PUT},
                new Route(){UrlRegex="/VIID/Cases/(.*)/Info$",Method= HttpMethods.DELETE,Name = "删除视频案事件对象信息",Callable = Cases.ID.Info.DELETE},
                //new Route(){UrlRegex="/VIID/VideoSlices",Method= HttpMethods.POST,Name = "批量创建人工采集视频片段",Callable = VideoSlices.POST},
                new Route(){UrlRegex="/VIID/VideoSlices/(.*)$",Method= HttpMethods.PUT,Name = "更新人工采集单个视频片段",Callable = VideoSlices.ID.PUT},
                new Route(){UrlRegex="/VIID/VideoSlices/(.*)$",Method= HttpMethods.DELETE,Name = "删除人工采集单个视频片段",Callable = VideoSlices.ID.DELETE},
                new Route(){UrlRegex="/VIID/VideoSlices/(.*)/Info$",Method= HttpMethods.PUT,Name = "更新人工采集视频片段对象信息",Callable = VideoSlices.ID.Info.PUT},
                new Route(){UrlRegex="/VIID/VideoSlices/(.*)/Info$",Method= HttpMethods.DELETE,Name = "删除人工采集视频片段对象信息",Callable = VideoSlices.ID.Info.DELETE},
                new Route(){UrlRegex="/VIID/VideoSlices/(.*)/Data$",Method= HttpMethods.POST,Name = "创建人工采集视频片段数据",Callable = VideoSlices.ID.Data.POST},
                new Route(){UrlRegex="/VIID/VideoSlices/(.*)/Data$",Method= HttpMethods.DELETE,Name = "删除人工采集视频片段数据",Callable = VideoSlices.ID.Data.DELETE},
                new Route(){UrlRegex="/VIID/VideoImages",Method= HttpMethods.POST,Name = "批量创建人工采集图像",Callable = VideoImages.POST},
                new Route(){UrlRegex="/VIID/VideoImages/(.*)$",Method= HttpMethods.PUT,Name = "更新人工采集单个图像",Callable = VideoImages.ID.PUT},
                new Route(){UrlRegex="/VIID/VideoImages/(.*)$",Method= HttpMethods.DELETE,Name = "删除人工采集单个图像",Callable = VideoImages.ID.DELETE},
                new Route(){UrlRegex="/VIID/VideoImages/(.*)/Info$",Method= HttpMethods.PUT,Name = "更新人工采集图像对象信息",Callable = VideoImages.ID.Info.PUT},
                new Route(){UrlRegex="/VIID/VideoImages/(.*)/Info$",Method= HttpMethods.DELETE,Name = "删除人工采集图像对象信息",Callable = VideoImages.ID.Info.DELETE},
                new Route(){UrlRegex="/VIID/VideoImages/(.*)/Data$",Method= HttpMethods.POST,Name = "创建人工采集图像数据",Callable = VideoImages.ID.Data.POST},
                new Route(){UrlRegex="/VIID/VideoImages/(.*)/Data$",Method= HttpMethods.DELETE,Name = "删除人工采集图像数据",Callable = VideoImages.ID.Data.DELETE},
                new Route(){UrlRegex="/VIID/VideoFiles",Method= HttpMethods.POST,Name = "批量创建人工采集文件",Callable = VideoFiles.POST},
                new Route(){UrlRegex="/VIID/VideoFiles/(.*)$",Method= HttpMethods.PUT,Name = "更新人工采集单个文件",Callable = VideoFiles.ID.PUT},
                new Route(){UrlRegex="/VIID/VideoFiles/(.*)$",Method= HttpMethods.DELETE,Name = "删除人工采集单个文件",Callable = VideoFiles.ID.DELETE},
                new Route(){UrlRegex="/VIID/VideoFiles/(.*)/Info$",Method= HttpMethods.PUT,Name = "更新人工采集文件对象信息",Callable = VideoFiles.ID.Info.PUT},
                new Route(){UrlRegex="/VIID/VideoFiles/(.*)/Info$",Method= HttpMethods.DELETE,Name = "删除人工采集文件对象信息",Callable = VideoFiles.ID.Info.DELETE},
                new Route(){UrlRegex="/VIID/VideoFiles/(.*)/Data$",Method= HttpMethods.POST,Name = "创建人工采集文件数据",Callable = VideoFiles.ID.Data.POST},
                new Route(){UrlRegex="/VIID/VideoFiles/(.*)/Data$",Method= HttpMethods.DELETE,Name = "删除人工采集文件数据",Callable = VideoFiles.ID.Data.DELETE},
                //new Route(){UrlRegex="/VIID/Persons",Method= HttpMethods.POST,Name = "批量创建人员",Callable = Persons.POST},
                new Route(){UrlRegex="^/VIID/Persons$",Method= HttpMethods.PUT,Name = "批量更新人员",Callable = Persons.PUT},
                new Route(){UrlRegex="/VIID/Persons",Method= HttpMethods.DELETE,Name = "批量删除人员",Callable = Persons.DELETE},
                new Route(){UrlRegex="/VIID/Persons/(.*)$",Method= HttpMethods.PUT,Name = "更新单个人员",Callable = Persons.ID.PUT},
                new Route(){UrlRegex="/VIID/Persons/(.*)$",Method= HttpMethods.DELETE,Name = "删除单个人员",Callable = Persons.ID.DELETE},
                //new Route(){UrlRegex="/VIID/Faces",Method= HttpMethods.POST,Name = "批量创建人脸",Callable = Faces.POST},
                new Route(){UrlRegex="^/VIID/Faces$",Method= HttpMethods.PUT,Name = "批量更新人脸",Callable = Faces.PUT},
                new Route(){UrlRegex="/VIID/Faces",Method= HttpMethods.DELETE,Name = "批量删除人脸",Callable = Faces.DELETE},
                new Route(){UrlRegex="/VIID/Faces/(.*)$",Method= HttpMethods.PUT,Name = "更新单个人脸",Callable = Faces.ID.PUT},
                new Route(){UrlRegex="/VIID/Faces/(.*)$",Method= HttpMethods.DELETE,Name = "删除单个人脸",Callable = Faces.ID.DELETE},
                //new Route(){UrlRegex="/VIID/MotorVehicles",Method= HttpMethods.POST,Name = "批量创建机动车",Callable = MotorVehicles.POST},
                new Route(){UrlRegex="^/VIID/MotorVehicles$",Method= HttpMethods.PUT,Name = "批量更新机动车",Callable = MotorVehicles.PUT},
                new Route(){UrlRegex="/VIID/MotorVehicles",Method= HttpMethods.DELETE,Name = "批量删除机动车",Callable = MotorVehicles.DELETE},
                new Route(){UrlRegex="/VIID/MotorVehicles/(.*)$",Method= HttpMethods.PUT,Name = "更新单个机动车",Callable = MotorVehicles.ID.PUT},
                new Route(){UrlRegex="/VIID/MotorVehicles/(.*)$",Method= HttpMethods.DELETE,Name = "删除单个机动车",Callable = MotorVehicles.ID.DELETE},
                //new Route(){UrlRegex="/VIID/NonMotorVehicles",Method= HttpMethods.POST,Name = "批量创建非机动车",Callable = NonMotorVehicles.POST},
                new Route(){UrlRegex="^/VIID/NonMotorVehicles$",Method= HttpMethods.PUT,Name = "批量更新非机动车",Callable = NonMotorVehicles.PUT},
                new Route(){UrlRegex="/VIID/NonMotorVehicles",Method= HttpMethods.DELETE,Name = "批量删除非机动车",Callable = NonMotorVehicles.DELETE},
                new Route(){UrlRegex="/VIID/NonMotorVehicles/(.*)$",Method= HttpMethods.POST,Name = "更新单个非机动车",Callable = NonMotorVehicles.ID.POST},
                new Route(){UrlRegex="/VIID/NonMotorVehicles/(.*)$",Method= HttpMethods.DELETE,Name = "删除单个非机动车",Callable = NonMotorVehicles.ID.DELETE},
                //new Route(){UrlRegex="/VIID/Things",Method= HttpMethods.POST,Name = "批量创建物品",Callable = Things.POST},
                new Route(){UrlRegex="^/VIID/Things$",Method= HttpMethods.PUT,Name = "批量更新物品",Callable = Things.PUT},
                new Route(){UrlRegex="/VIID/Things",Method= HttpMethods.DELETE,Name = "批量删除物品",Callable = Things.DELETE},
                new Route(){UrlRegex="/VIID/Things/(.*)$",Method= HttpMethods.PUT,Name = "更新单个物品",Callable = Things.ID.PUT},
                new Route(){UrlRegex="/VIID/Things/(.*)$",Method= HttpMethods.DELETE,Name = "删除单个物品",Callable = Things.ID.DELETE},
                //new Route(){UrlRegex="/VIID/Scenes",Method= HttpMethods.POST,Name = "批量创建场景",Callable = Scenes.POST},
                new Route(){UrlRegex="^/VIID/Scenes$",Method= HttpMethods.PUT,Name = "批量更新场景",Callable = Scenes.PUT},
                new Route(){UrlRegex="/VIID/Scenes",Method= HttpMethods.DELETE,Name = "批量删除场景",Callable = Scenes.DELETE},
                new Route(){UrlRegex="/VIID/Scenes/(.*)$",Method= HttpMethods.PUT,Name = "更新单个场景",Callable = Scenes.ID.PUT},
                new Route(){UrlRegex="/VIID/Scenes/(.*)$",Method= HttpMethods.DELETE,Name = "删除单个场景",Callable = Scenes.ID.DELETE},
                //new Route(){UrlRegex="/VIID/VideoLabels",Method= HttpMethods.POST,Name = "创建视频图像标签",Callable = VideoLabels.POST},
                new Route(){UrlRegex="^/VIID/VideoLabels$",Method= HttpMethods.PUT,Name = "更新视频图像标签",Callable = VideoLabels.PUT},
                new Route(){UrlRegex="/VIID/VideoLabels",Method= HttpMethods.DELETE,Name = "删除视频图像标签",Callable = VideoLabels.DELETE},
                //new Route(){UrlRegex="/VIID/AnalysisRules",Method= HttpMethods.POST,Name = "批量创建视频图像分析规则",Callable = AnalysisRules.POST},
                new Route(){UrlRegex="^/VIID/AnalysisRules$",Method= HttpMethods.PUT,Name = "批量更新视频图像分析规则",Callable = AnalysisRules.PUT},
                new Route(){UrlRegex="/VIID/AnalysisRules",Method= HttpMethods.DELETE,Name = "批量删除视频图像分析规则",Callable = AnalysisRules.DELETE},
            };

            Console.WriteLine("启动服务器");

            httpServer = new HttpServer(_options.port, route_config);
            thread = new Thread(new ThreadStart(httpServer.Listen));
            thread.Start();
            return true;
        }
    }
}
